package com.ws.shop.action.admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.ui.Model;

import com.ws.shop.bean.SystemConfig;
import com.ws.shop.util.RequestUtil;
import com.ws.shop.util.SystemConfigUtil;


public class ConfigAction extends BaseAdminAction{
	
	public String index(Model model){
		model.addAttribute("systemConfig", SystemConfigUtil.getSystemConfig());
		return "config_index";
	}
	
	public String save(HttpServletRequest request,HttpServletResponse response){
		SystemConfig config = new SystemConfig();
		config.setServices_tel(RequestUtil.getStringParameter(request, "services_tel", ""));
		config.setWebsite(RequestUtil.getStringParameter(request, "website", ""));
		config.setServices_email(RequestUtil.getStringParameter(request, "services_email", ""));
		config.setCopyright(RequestUtil.getStringParameter(request, "copyright", ""));
		config.setWebname(RequestUtil.getStringParameter(request, "webname", ""));
		config.setBeat_name(RequestUtil.getStringParameter(request, "beat_name", ""));
		config.setKeywords(RequestUtil.getStringParameter(request, "keywords", ""));
		config.setDescription(RequestUtil.getStringParameter(request, "description", ""));
		config.setWork_time(RequestUtil.getStringParameter(request, "work_time", ""));
		config.setIcp(RequestUtil.getStringParameter(request, "icp", ""));
		config.setSina_blog(RequestUtil.getStringParameter(request, "sina_blog", ""));
		config.setPointb_name(RequestUtil.getStringParameter(request, "pointb_name", ""));
		config.setSms_Interface(RequestUtil.getStringParameter(request, "sms_Interface", ""));
		config.setSms_success(RequestUtil.getStringParameter(request, "sms_success", ""));
		config.setGift_pointb(RequestUtil.getStringParameter(request, "gift_pointb", ""));
		config.setPunch_pointb(RequestUtil.getStringParameter(request, "punch_pointb", ""));
		config.setRmb_beat(RequestUtil.getStringParameter(request, "rmb_beat", ""));
		config.setMemcache_prefix(RequestUtil.getStringParameter(request, "memcache_prefix", ""));
		config.setMemcache_server(RequestUtil.getStringParameter(request, "memcache_server", ""));
		config.setMemcache_pconnect(RequestUtil.getStringParameter(request, "memcache_pconnect", ""));
		config.setMemcache_port(RequestUtil.getIntParameter(request, "memcache_port", 8081));
		config.setEaccelerator(RequestUtil.getIntParameter(request, "eaccelerator", 0));
		config.setXcache(RequestUtil.getIntParameter(request, "xcache", 0));
		config.setInvite(RequestUtil.getIntParameter(request, "invite", 0));
		config.setPointc_name(RequestUtil.getStringParameter(request, "pointc_name", ""));
		config.setOrder_expired(RequestUtil.getIntParameter(request, "order_expired", 0));
		config.setUpload_head(RequestUtil.getIntParameter(request, "upload_head", 0));
		config.setMauction_time(RequestUtil.getIntParameter(request, "mauction_time", 0));
		config.setEauction_time(RequestUtil.getIntParameter(request, "eauction_time", 0));
		config.setLetter_replacestr(RequestUtil.getStringParameter(request, "letter_replacestr", ""));
		config.setRobots_probability(RequestUtil.getIntParameter(request, "robots_probability", 0));
		
		SystemConfigUtil.update(config);
		return this.ajaxJsonSuccessMessage(response, "操作成功");
	}
}
